/**
* @Author: zmx
* @Date: 2023/9/25
* @Description:
*/
<template>
  <div style="padding: 20px">
    <el-form :inline="true" :model="formInline">
      <el-form-item label="操作人员：">
        <el-input v-model="formInline.operName" placeholder="操作人员："></el-input>
      </el-form-item>
<!--      <el-form-item label="操作类型：">-->
<!--        <el-select-->
<!--          v-model="formInline.operType"-->
<!--          value-key="id"-->
<!--          filterable-->
<!--          clearable-->
<!--        >-->
<!--          <el-option-->
<!--            v-for="item in optionsList"-->
<!--            :key="item.value"-->
<!--            :label="item.name"-->
<!--            :value="item.value"-->
<!--          />-->
<!--        </el-select>-->
<!--      </el-form-item>-->
      <el-form-item label="系统模块：">
        <el-select
          v-model="formInline.moduleName"
          value-key="id"
          filterable
          clearable
        >
          <el-option
            v-for="item in optionsList"
            :key="item.name"
            :label="item.name"
            :value="item.name"
          />
        </el-select>
<!--        <el-input v-model="formInline.moduleName" placeholder="系统模块："></el-input>-->
      </el-form-item>
      <el-form-item label="操作时间：">
        <el-date-picker
          v-model="formInline.time"
          type="datetimerange"
          range-separator="至"
          value-format="yyyy-MM-dd HH:mm:ss"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <el-button @click="reset">清空</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" style="width: 100%" :header-cell-style="{background:'#006175',color:'#fff'}">
      <el-table-column label="序号" width="50">
        <template v-slot="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column label="系统模块" width="180">
        <template v-slot="scope">
          {{ scope.row.moduleName.split('-')[0] }}
        </template>
      </el-table-column>
      <el-table-column  label="操作类型">
        <template v-slot="scope">
          {{ openType[scope.row.operType] + (scope.row.moduleName.split('-')[1]?scope.row.moduleName.split('-')[1]:'') }}
        </template>
      </el-table-column>
      <el-table-column prop="operName" label="操作人员"></el-table-column>
      <el-table-column prop="operIp" label="操作地址"></el-table-column>
      <el-table-column prop="createTime" label="操作时间"></el-table-column>
    </el-table>
    <el-pagination
      style="margin-top: 20px"
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
      :page-size="pagination.pageSize"
      layout="total, sizes, pager, next, jumper"
      :total="pagination.total">
    </el-pagination>
  </div>
</template>

<script>
import {log} from "../../api/inspection/apiUntil";
export default {
  data() {
    return {
      option: [],
      tableData: [],
      tableDataExpansion:[],
      title: '',
      titlePatrol: '',
      openType:{
        1:'增加',
        2:':删除',
        3:'修改',
        4:'查询',
      },
      row: '',
      formInline: {
        moduleName: '',
        operType:'',
        operName:'',
        time: '',
      },
      pagination: {
        pageNum: 1,
        pageSize: 10,
        total: 0
      },
      DialogComponentShow: false,
      DialogPatrolShow: false,
      // optionsList: [
      //   {
      //     name: '增',
      //     value: '1'
      //   },
      //   {
      //     name: '删',
      //     value: '2'
      //   },
      //   {
      //     name: '改',
      //     value: '3'
      //   },
      //   {
      //     name: '查',
      //     value: '4'
      //   }
      // ],
      optionsList: [
        {
          name: '风险评估',
        },
        {
          name: '远程巡检',
        },
        {
          name: '运营分析',
        },
        {
          name: '故障诊断',
        }
      ],
    };
  },
  mounted() {
    this.getInit()
  },
  methods: {
    handleSizeChange(val) {
      this.pagination.pageSize = val
      this.getInit()
    },
    handleCurrentChange(val) {
      this.pagination.pageNum = val
      this.getInit()
    },
    //列表
    getInit() {
      let params = {
        pageNum: this.pagination.pageNum,
        pageSize: this.pagination.pageSize,
        moduleName: this.formInline.moduleName,
        operType:this.formInline.operType,
        operName:this.formInline.operName,
        beginTime:this.formInline.time[0],
        endTime:this.formInline.time[1]
      }
      log.getLogQuery(params).then((res) => {
        if (res) {
          this.tableData = res.list
          this.pagination.total = res.total
          console.log('chongfy')
        }
      })
    },
    onSubmit() {
      this.getInit()
    },
    //手动清空
    reset() {
      this.formInline.moduleName = ''
      this.formInline.operType = ''
      this.formInline.operName = ''
      this.formInline.time = ''
      this.getInit()
    },
  }
};

</script>

<style scoped>

</style>
